<?php include '_init_.php';?>
<?php
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';

if($act == 'delete')
{
	if($_REQUEST['users'])
	{
		$dt = new DataTable(constant('DB_TABLE_USER'));
		foreach($_REQUEST['users'] as $tmpId)
		{
			$dt->remove(intval($tmpId));
		}
	}
}
?>
<?php include 'page_header.php';?>
<div id="main"><!-- start #main //-->
<div id="tita"> <!-- start #tita //-->
<?php define('ADMIN_NAVIGATOR_ITEM','系統管理');?>
<?php include 'navigator_admin.php';?>
<?php define('ADMIN_MENU_CURRENT_ITEM','系統管理');?>
<?php include 'admin_menu.php';?>

<script language="javascript">
function edit_to_edit() {
	var url = '';
	if($('#div_account_admin_container input[type=checkbox][checked]').length == 1)
	{
		url = "backstageei.php?act=edit&isadmin=1&id="+$('#div_account_admin_container input[type=checkbox][checked]').val();
		rAlert(url, null, "系統管理帳號", 704, 200);
	}else{
		alert('請選擇一個系統管理帳號');
		return false;
	}
	
}
function edit_to_new(isadmin)
{
	var url = 'backstageei.php?act=new&isadmin=1';
	rAlert(url, null, "統總管理帳號", 704, 200);
}

function edit_tob_edit() {
	var url = '';
	if($('#div_account_normal_container input[@type=checkbox][checked]').length == 1)
	{
		url = "backstageei.php?act=edit&isadmin=0&id="+$('#div_account_normal_container input[@type=checkbox][checked]').val();
		rAlert(url, null, "操作人員帳號", 704, 220);
	}else{
		alert('請選擇一個操作人員帳號');
		return false;
	}
	
}
function edit_tob_new(isadmin)
{
	var url = 'backstageei.php?act=new&isadmin=0';
	rAlert(url, null, "操作人員帳號", 704, 220);
}
</script>
<?php
$dt = new DataTable(constant('DB_TABLE_USER'));
$admin_list = array();
$csr_list = array();
$photo_list = array();
$product_list = array();
$tmp_list = $dt->get_list();
foreach($tmp_list as $tmpData)
{
	if($tmpData['is_admin'] == 'Y')
	{
		$admin_list[] = $tmpData;
	}
	if($tmpData['is_csr'] == 'Y')
	{
		$csr_list[] = $tmpData;
	}
	if($tmpData['is_photo'] == 'Y')
	{
		$photo_list[] = $tmpData;
	}
	if($tmpData['is_product'] == 'Y')
	{
		$product_list[] = $tmpData;
	}
}
?>
<div class="clearfix" id="mainf"><!-- start #mainf //-->

<div class="mainf-3" id="div_account_admin_container"><!-- start 系統管理帳號 //-->
<script language="javascript">
function delete_account_admin()
{
	if(confirm('Delete selected')){document.forms['form_account_admin'].submit();} 
	return false;
}
</script>
<form method="post" name="form_account_admin">
<input type="hidden" name="act" value="delete"/>
<ul>
      <li class="maina-1i">客服系統總管理帳號</li>
      <li class="maina-1f2">系統管理帳號</li>
      	<?php foreach($admin_list as $tmpData):?>
      	<li class="maina-1a">
        <input type="checkbox"  name="users[]" value="<?php echo $tmpData['id'];?>"/>
        <?php echo Util::html_safe($tmpData['login_user']);?></li>
      	<?php endforeach;?>
        <li class="maina-1d">
        <a onclick="javascript:edit_to_new();return false;" href="#"><img width="60" height="17" src="images/backstage-btn-5.gif"></a>
        <a onclick="javascript:edit_to_edit();return false;" href="#"><img width="60" height="17" src="images/backstage-btn-6.gif"></a>
        <a href="#del" onclick="return delete_account_admin();"><img width="60" height="17" src="images/backstage-btn-7.gif"></a>
        </li>
       </ul>
</form>
</div><!-- end 系統管理帳號 //-->


<div class="mainf-3" id="div_account_normal_container"><!-- start 操作人員帳號管理 //-->
<script language="javascript">
function delete_account_normal()
{
	if(confirm('Delete selected')){document.forms['form_account_normal'].submit();} 
	return false;
}
</script>
<form method="post" name="form_account_normal">
<input type="hidden" name="act" value="delete"/>
<ul>
      <li class="maina-1i">操作人員帳號管理</li>
         <li class="maina-1f2">門市部及客服部</li>
         <?php foreach($csr_list as $tmpData):?>
      	<li class="mainf-1c">
        <input type="checkbox"  name="users[]" value="<?php echo $tmpData['id'];?>"/>
        <?php echo Util::html_safe($tmpData['login_user']);?></li>
      	<?php endforeach;?>
       
      
      <li class="maina-1f2">攝影部及造型部</li>
      <?php foreach($photo_list as $tmpData):?>
      	<li class="mainf-1c">
        <input type="checkbox"  name="users[]" value="<?php echo $tmpData['id'];?>"/>
        <?php echo Util::html_safe($tmpData['login_user']);?></li>
      	<?php endforeach;?>
      
      
      <li class="maina-1f2">製作部</li>
      <?php foreach($product_list as $tmpData):?>
      	<li class="mainf-1c">
        <input type="checkbox"  name="users[]" value="<?php echo $tmpData['id'];?>"/>
        <?php echo Util::html_safe($tmpData['login_user']);?></li>
      	<?php endforeach;?>
      
      
      
        <li class="maina-1d">
        <a onclick="javascript:edit_tob_new();return false;" href="#"><img width="60" height="17" src="images/backstage-btn-5.gif"></a>
        <a onclick="javascript:edit_tob_edit();return false;" href="#"><img width="60" height="17" src="images/backstage-btn-6.gif"></a>
        <a href="#del" onclick="return delete_account_normal();"><img width="60" height="17" src="images/backstage-btn-7.gif"></a>
        </li>
       </ul>
</form>
</div><!-- end 操作人員帳號管理 //-->

</div><!-- end #mainf //-->
</div><!-- end #tita //-->
</div><!-- end #main //-->
<?php include 'page_footer.php';?>